<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title>径向渐变</title>
		<style type="text/css">
			* {
				padding: 0;
				margin: 0;
			}
			
			.container {
				width: 100vw;
				height: 100vh;
				display: flex;
				align-items: center;
				justify-content: center;
			}
			
			canvas {
				width: 500px;
				height: 500px;
				border: 2px solid blue;
			}
		</style>
	</head>

	<body>
		<div class="container">
			<canvas id="canvas" width="500" height="500"></canvas>
		</div>
	</body>
	<script type="text/javascript">
		window.onload = function() {
			let oCanvas = document.getElementById('canvas');
			console.dir(oCanvas);
			let oPen = oCanvas.getContext("2d");
			//开始渐变点的坐标 ，半径，渐变 结束时圆心坐标 ,结束时的半径
			//createRadialGradient(x1,y1,r1,x2,y2,r2)
			
			var oJb=oPen.createRadialGradient(300,230,20,250,250,150);
			oJb.addColorStop(0,"white");
			oJb.addColorStop(0.7,"pink");
			oJb.addColorStop(1,"red");
			
			oPen.fillStyle=oJb;
			
			oPen.arc(250,250,150,0,Math.PI*2,true);
		    oPen.fill();
		}
	</script>
	</body>

</html>